package com.reason.search.controller;

import com.reason.common.pojo.Result;
import com.reason.common.pojo.StatusCode;
import com.reason.search.service.EsManagerService;
import com.reason.search.service.impl.EsManagerServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhangHeng
 * @date: 2020/6/30 10:24
 */
@RestController
@RequestMapping("/manager")
public class EsManagerController {
    @Autowired
    private EsManagerService esManagerService;
    //创建索引
    @RequestMapping("/create")
    public Result createMappingAndIndex(){
        esManagerService.createMappingAndIndex();
        return new Result(true, StatusCode.OK,"创建索引库成功");
    }

    //将数据导入索引库
    @RequestMapping("/importAll")
    public Result importAll(){
        esManagerService.importAll();
        return new Result(true, StatusCode.OK,"导入全部数据成功");
    }
}
